<?php

namespace App\Providers;

use App\Models\Ad;
use App\Models\DeviceOrder;
use App\Models\FactoryDevice;
use App\Models\FactoryStatistical;
use App\Models\Group;
use App\Models\GroupMember;
use App\Models\GroupPolicy;
use App\Models\MarketingPolicy;
use App\Models\MarketingPolicyRule;
use App\Models\PriceSpecification;
use App\Models\User;
use App\Policies\AdPolicy;
use App\Policies\DeviceOrderPolicy;
use App\Policies\FactoryDevicePolicy;
use App\Policies\FactoryStatisticalPolicy;
use App\Policies\GroupMemberPolicy;
use App\Policies\GroupPolicyPolicy;
use App\Policies\MarketingPolicyPolicy;
use App\Policies\MarketingPolicyRulePolicy;
use App\Policies\PriceSpecificationPolicy;
use App\Policies\UserPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Carbon;
use Laravel\Passport\Passport;
use App\Models\Device;
use App\Policies\DevicePolicy;
use Illuminate\Support\Facades\Route;
class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        // 'App\Model' => 'App\Policies\ModelPolicy',
        FactoryDevice::class=>FactoryDevicePolicy::class,
        FactoryStatistical::class=>FactoryStatisticalPolicy::class,
        User::class=>UserPolicy::class,
        GroupPolicy::class=>GroupPolicyPolicy::class,
        GroupMember::class=>GroupMemberPolicy::class,
        Group::class=>\App\Policies\GroupPolicy::class,
        DeviceOrder::class=>DeviceOrderPolicy::class,
        Ad::class=>AdPolicy::class,
        PriceSpecification::class=>PriceSpecificationPolicy::class,
        MarketingPolicy::class=>MarketingPolicyPolicy::class,
        MarketingPolicyRule::class=>MarketingPolicyRulePolicy::class,
        Device::class=>DevicePolicy::class,
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();
        Route::group(['middleware' => 'oauth.providers'], function () {
            Passport::routes(function ($router) {
                return $router->forAccessTokens();
            });
        });
        Passport::tokensExpireIn(Carbon::now()->addDays(15));
        Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));
    }
}
